﻿@{
    ViewBag.Title = "ApplyIndex";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        $("#txtOStatus").bindSelect({
            url: "/SystemManage/ItemsData/GetSelectJson",
            param: { enCode: "schoolOStatus" }
        });
        $("#txtOStatus").bindSelect({
            url: "/SystemManage/ItemsData/GetSelectJson",
            param: { enCode: "eduOStatus" }
        });
        $("#txtHouseFlag").bindSelect({
            url: "/SystemManage/ItemsData/GetSelectJson",
            param: { enCode: "HouseFlag" }
        });
        $("#txtSchoolId").bindSelect({
            url: "/Gas/Apply/GetEnableSchoolSelectJson",
        });
        $("#txtClass").bindSelect({
            url: "/SystemManage/ItemsData/GetSelectJson",
              param: { enCode: "Class" }
        });
        $("#txtHouseClass").bindSelect({
            url: "/Gas/Apply/GetHouseClass",
        });
        
        $("#txtIsPwdKeyApply").bindSelect({
            url: "/SystemManage/ItemsData/GetSelectJson",
            param: { enCode: "ApplyType" }
        });
        
        gridList();
        $("#gridList").jqGrid('setLabel', 'rn', '序号', { 'text-align': 'center', 'vertical-align': 'middle', 'width': '50' });
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/Gas/Apply/GetGridJsonByEdu",
            height: $(window).height() - 96,
            colModel: [
                { label: "主键", name: "F_Id", hidden: true, key: true },
                { label: "排位号", name: "ApplyNumber", width: 100, align: 'center' },
                { label: "手机号", name: "Phone", width: 100, align: 'left' },
                { label: "学生姓名", name: "StudentName", width: 100, align: 'center' },
                
                {
                    label: '第一志愿学校', name: 'SchoolId', width: 150, align: 'center',
                    formatter: function (cellvalue) {
                        return top.clients.schoolItems[cellvalue] == undefined ? "" : top.clients.schoolItems[cellvalue].schoolName
                    }
                },
                {
                    label: '年级', name: 'Class', width: 100, align: 'center',
                    formatter: function (cellvalue) {
                        return top.clients.dataItems["Class"][cellvalue] == undefined ? "" : top.clients.dataItems["Class"][cellvalue]
                    }
                },
                {
                    label: '状态', name: 'OStatus', width: 100, align: 'center',
                    formatter: function (cellvalue) {
                        if (top.clients.dataItems["schoolOStatus"][cellvalue] != undefined) {
                            return top.clients.dataItems["schoolOStatus"][cellvalue];
                        }
                        if (top.clients.dataItems["studentOStatus"][cellvalue] != undefined) {
                            return top.clients.dataItems["studentOStatus"][cellvalue];
                        }
                        if (top.clients.dataItems["eduOStatus"][cellvalue] != undefined) {
                            return top.clients.dataItems["eduOStatus"][cellvalue];
                        }
                    }
                },
                {
                    label: '提交方式', name: 'isPwdKeyApply', width: 100, align: 'center',
                    formatter: function (cellvalue) {
                        return ("1" == cellvalue) ? "验证码提交" : "正常提交"
                    }
                },
                { label: '学生原所在学校全称', name: 'OriginalSchool', width: 150, align: 'left' },
                {
                    label: '第二志愿学校', name: 'SecondSchoolId', width: 150, align: 'center',
                    formatter: function (cellvalue) {
                        return top.clients.schoolItems[cellvalue] == undefined ? "" : top.clients.schoolItems[cellvalue].schoolName
                    }
                },
                {
                    label: '学生家庭情况', name: 'FamilySituation', width: 150, align: 'center',
                    formatter: function (cellvalue) {
                        return (top.clients.dataItems["FamilySituation"][cellvalue] == undefined || top.clients.dataItems["FamilySituation"][cellvalue] == "请选择") ? "" : top.clients.dataItems["FamilySituation"][cellvalue]
                    }
                },
                { label: '学生身份证号', name: 'IDNumber', width: 150, align: 'left' },
                {
                    label: '住房类型', name: 'HouseFlag', width: 280, align: 'left',
                    formatter: function (cellvalue) {
                        return top.clients.dataItems["HouseFlag"][cellvalue] == undefined ? "" : top.clients.dataItems["HouseFlag"][cellvalue]
                    }
                },
                { label: '住房所属大类', name: 'HouseClass', width: 100, align: 'center' },
                { label: 'A_1_房证上登记地址', name: 'A_CertificateAddress', width: 300, align: 'center' },
                { label: 'A_2_购房合同登记地址', name: 'A_CertificateAddress2', width: 300, align: 'left' },
                { label: 'B_1_租房地址', name: 'C_RentAddress', width: 300, align: 'left' },
                { label: 'B_2_现居住地址', name: 'C_RentAddress1', width: 300, align: 'left' },
                {
                    label: '家长申请时间', name: 'LastUpdateTime', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return ("1900-01-01 00:00:00" == cellvalue) ? "" : cellvalue;
                    }
                },
                { label: '最终提交审核时间', name: 'F_LastModifyTime', width: 150, align: 'left' },
            ],
            pager: "#gridPager",
            sortname: 'F_LastModifyTime asc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { RName: $("#txtRName").val(), IDNumber: $("#txtIDNumber").val(), OStatus: $("#txtOStatus").val(), schoolId: $("#txtSchoolId").val(), txtHouseFlag: $("#txtHouseFlag").val(), HouseClass: $("#txtHouseClass").val(), IsPwdKeyApply: $("#txtIsPwdKeyApply").val(), classValue: $("#txtClass").val() },
            }).trigger('reloadGrid');
        });
    }
    function btn_update() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        if (keyValue == null || keyValue == "") {
            bootbox.alert("请选择想要更新的申请");
            return;
        } else {
            window.location.href = "/Gas/Apply/Update?keyValue=" + keyValue + "&eduRole=1";
        }
    }
    function btn_updateOStatus() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        if (keyValue == null || keyValue == "") {
            bootbox.alert("请选择想要更新的申请");
            return;
        } else {
            window.location.href = "/Gas/Apply/OStatusUpdate?keyValue=" + keyValue;
        }
    }
    function btn_details() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        if (keyValue == null || keyValue == "") {
            bootbox.alert("请选择想要查看的申请");
            return;
        } else {
            window.location.href = "/Gas/Apply/Details?keyValue=" + keyValue + "&eduRole=1";
        }
    }
    function btn_delete() {
        $.deleteForm({
            url: "/Gas/Apply/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().F_Id },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_DownloadApplyInfo() {
        window.location.href = "/Gas/Apply/ExportApplyInfo?RName=" + $("#txtRName").val() + "&IDNumber=" + $("#txtIDNumber").val() + "&classValue=" + $("#txtClass").val()
            + "&OStatus=" + $("#txtOStatus").val() + "&schoolId=" + $("#txtSchoolId").val() + "&txtHouseFlag=" + $("#txtHouseFlag").val()
            + "&HouseClass=" + $("#txtHouseClass").val() + "&IsPwdKeyApply=" + $("#txtIsPwdKeyApply").val();
    }
</script>
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            <a href="#" id="NF-DownloadApplyInfo" class="btn btn-primary" onclick="btn_DownloadApplyInfo()"><span class="glyphicon glyphicon-download">导出报名结果</span></a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-info" onclick="btn_details()"><i class="fa fa-info"></i>详情</a></li>
                <li><a id="NF-delete" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除</a></li>
                @*<li><a id="NF-edit" onclick="btn_update()"><i class="fa fa-pencil-square-o"></i>修改</a></li>*@
                <li><a id="NF-edit" onclick="btn_updateOStatus()"><i class="fa fa-pencil-square-o"></i>状态</a></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txtRName" type="text" class="form-control" placeholder="学生姓名" style="width: 100px;">
                        <input id="txtIDNumber" type="text" class="form-control" placeholder="学生身份证号" style="width: 120px;">
                        <select id="txtOStatus" class="form-control" style="width:110px">
                            <option value="">请选择录取状态</option>
                            <option value="2">提交</option>
                        </select>
                        <select id="txtHouseFlag" class="form-control" style="width:120px"></select>
                        <select id="txtSchoolId" class="form-control" style="width:110px"></select>
                        <select id="txtClass" class="form-control" style="width:80px">
                            <option value="">请选择年级</option>
                        </select>
                        <select id="txtHouseClass" class="form-control" style="width:130px"></select>
                        <select id="txtIsPwdKeyApply" class="form-control" style="width:110px">
                            <option value="">请选择提交方式</option>
                        </select>
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
<div id="my-modal" class="modal fade" data-placement="center" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>